home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Unix
/
Piper
/
SampleScripts
/
Compress
/
script
< prev
Wrap
Text File
|
1993-01-25
|
3KB
|
62 lines
#!/bin/csh
#I am beginning to hate csh.
#Maybe I might like perl?
if("$1" != "") then
#If this isn't eliminated,
#your home directory might be compressed
#if something goes wrong with Services or so.
#I've experienced this before I put some tests in,
#and it was frightening, because as I killed the
#tar, the rm -r kicked in!
#And there was no compressed version yet!
#I hope this will cure everything...
if -f "$1" then
#echo It was a file named \""$1"\" >/dev/console
if -e "$1".Z then
echo Compress file: "$1".Z already exists. Cancelled. >/dev/console
exit(-1)
else if ( ! -r "$1" ) then
echo Compress file: cannot read file. Cancelled. >/dev/console
exit(-1)
else if ( "$1" =~ *.Z ) then
echo Compress file: is already compressed. Cancelled. >/dev/console
exit(-1)
else if ! { touch "$1".Z } then
echo Compress file: cannot write in folder. Cancelled. >/dev/console
exit(-1)
else
#echo compressing >/dev/console
#$1 is a file that I can read, it does not have extension .Z yet,
#compress will not overwrite anything and will succeed (I think).
rm "$1".Z #the last test created the file (better test, anyone?)
compress "$1"
endif
#echo kiekeboe2 >/dev/console
else if -d "$1" then
echo `echo "$1" | cat` >/dev/console
if -e "$1".tar.Z then
echo Warning: "$1".tar.Z already exists. Cancelled. >/dev/console
exit(-1)
else if ( ! -e "$1".tar.Z && "$1" == "`echo $1 | cat`" ) then
echo kiekeboe3 >/dev/console
#There should be more tests, or else I should be able to check
#the result of the compression before I delete anything.
#If you know how please tell me at RfSchtkt@banruc60.bitnet
cd "$1"/..
#We want relative paths in the compressed file!
#This might be superfluous in some version of Piper.
tar cf - "`echo $1 | sed -e 'ss/.*/ss'`" | compress > "$1".tar.Z
#Warning: the filename shouldn't contain tabs and multiple
#contiguous spaces, because `` will mutilate it otherwise.
#rm -r "$1" I won't risk this for any innocent user
#Uncomment if you want to assume responsibility for any errors.
else
echo Compress folder: something was wrong. Cancelled. >/dev/console
exit(-1)
endif
else
echo Compress: only for files and folders with 7-bit-character names! >/dev/console
exit(-1)
endif
endif